package com.example.demo.controller;

import com.example.demo.core.annotations.RestPack;
import com.example.demo.core.util.AssertUtil;
import com.example.demo.entity.User;
import com.example.demo.model.Result;
import com.example.demo.service.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("get")
    @RestPack
    User get(Integer id) {
        return new User(id, "喻杰");
    }

    @GetMapping("install")
    @RestPack
    public User install(String name) {
        AssertUtil.assertNotNull("参数不能为空", name);
        return userService.save(new User(name));
    }



}
